home *** CD-ROM | disk | FTP | other *** search
/ PD Collection CD 1 / PD Collection CD 1.iso / textual / tex / files / !tex / TeXsource / beebe / ps / dvialw next >
Encoding:
Text File  |  1987-01-08  |  7.9 KB  |  277 lines

  1. % <BEEBE.TEX.DVI>DVIALW.PS.13,  7-Jan-87 17:38:51, Edit by BEEBE
  2. % Add translate command to BOP so that (0,0) really corresponds to
  3. % the top left physical page corner.  The standard LaTeX file 
  4. % TESTPAGE.TEX can be used for this calibration; it might be sensitive
  5. % to the particular printer used.    
  6. % <BEEBE.TEX.DVI.NEW>DVIALW.PS.12, 10-Dec-86 17:24:50, Edit by BEEBE
  7. % Fix off-by-one error in definition of /B; to draw a box N pixels
  8. % wide, microscopic examination of output shows that the box width
  9. % must be N-1, not N, pixels; the boundary counts in the filling.                
  10. % <BEEBE.TEX.DVI.NEW>DVIALW.PS.9, 28-Nov-86 19:00:52, Edit by BEEBE
  11. % Change definition of EOP to use #copies and showpage
  12. % instead of {copypage} repeat erasepage
  13. % <BEEBE.TEX.DVI.NEW>DVIALW.PS.7, 16-Oct-86 13:09:36, Edit by BEEBE
  14. % Following Macintosh LaserWriter md dictionary, change most
  15. % def's to bdf's (bind def); this is claimed to speed up
  16. % operator access
  17. % <BEEBE.TEX.DVI.NEW>DVIALW.PS.5, 16-Oct-86 12:01:12, Edit by BEEBE
  18. % Change CTL-L to caret-L in comment
  19. % <BEEBE.TEX.DVI.NEW>DVIALW.PS.3, 13-Jun-86 10:48:39, Edit by BEEBE
  20. % Fix definition of NOTE, make it default in BOJ macro to try to reduce
  21. % incidence of VM errors
  22. % ----------------------------------------------------------------------
  23. % DVIALW PostScript macro definitions (keep in alphabetical order).  For
  24. % readability, these  are  heavily  commented,  but  we  adhere  to  the
  25. % convention that  percent is  used  ONLY to  mark  the beginning  of  a
  26. % comment (NEVER  occurs  inside a  PostScript  string), and  lines  are
  27. % limited to 80 characters.  That way, DVIALW can read these definitions
  28. % from a  file and  discard  comments and  trailing white  space  before
  29. % transmission to  the  PostScript output  file.   In the  interests  of
  30. % compactness, macros which  receive any significant  degree of use  are
  31. % given single letter names -- PostScript is already much too verbose.
  32. %
  33. % Coordinates are assumed to  be in pixels  (Resolution per inch).   The
  34. % page origin follows the  PostScript convention of  being in the  lower
  35. % left corner, y positive upwards along  the longer side of the page,  x
  36. % positive  to  the  right.   Letter  and  legal  sizes  are   therefore
  37. % equivalent as far as PostScript is concerned, but y coordinates can be
  38. % bigger in legal size.  In landscape mode, the page is rotated to place
  39. % the origin in  the upper left  corner, x positive  downward along  the
  40. % longer side of  the page, y  positive to the  right.  That way,  pages
  41. % eject from  the printer  upright when  viewed from  the front  of  the
  42. % printer.
  43. %
  44. % Document format is something like this:
  45. %
  46. %    %!PS-Adobe-1.0
  47. %    %%Dimensions: 0 0 612 792
  48. %    %%Title: DVIALW  -o1 -s300 foo12
  49. %    %%CreationDate: Sat Mar  8 10:52:52 1986
  50. %    %%Creator: BEEBE and [TeX82 DVI Translator Version 2.03b...]
  51. %    %%Pages: (atend)
  52. %    %%BugHistory: Incorporates save/restore and font reloading...
  53. %    %%BugHistory: Incorporates Allan Hetzel's 31-Oct-85 DARPA...
  54. %    %%EndComments
  55. %    %%EndProlog
  56. %    %%Page: 0 1
  57. %    TeXdict begin
  58. %    BOJ
  59. %    BOP
  60. %    ...
  61. %     1 EOP
  62. %    ^LBOP
  63. %    ...
  64. %     1 EOP
  65. %    ^LBOP
  66. %    ...
  67. %     1 EOP
  68. %    ^LEOJ
  69. %    %%Trailer
  70. %    %%Pages: 7
  71. %    %%PageTable:  0 1 3434
  72. %    ^D
  73. %
  74. % One formfeed is output  for each printed page  copy, in order to  make
  75. % spooler page accounting simple.  The additional comments wrapping  the
  76. % BOJ ..  EOJ  sequence conform  to  Adobe PostScript  file  structuring
  77. % conventions, and the first line can be used by the spooler to identify
  78. % the file as containing PostScript.
  79. % ----------------------------------------------------------------------
  80.  
  81.  
  82. /TeXdict 200 dict def        % dictionary for these definitions
  83. TeXdict begin
  84.  
  85. % bdf -- bind def (for efficiency)
  86. % Usage -- just like def, but not on constant objects
  87. /bdf {bind def} def
  88.  
  89. % B -- draw bar (TeX rule) of size w by h at currentpoint
  90. % Usage -- w h B
  91. /B
  92. {
  93.   /h exch def
  94.   /w exch def
  95.   gsave
  96.   currentpoint
  97.   newpath
  98.     moveto
  99.     w 1 sub 0 rlineto
  100.     0 h 1 sub rlineto
  101.     w 1 sub neg 0 rlineto
  102.   closepath fill
  103.   grestore
  104. } bdf
  105.  
  106. % BOJ -- beginning of job (EOF ends it and closes TeXdict)
  107. % Usage -- BOJ
  108. /BOJ
  109. {
  110.   72 Resolution div 72 Resolution div scale
  111.   NOTE                % default page format
  112. } bdf
  113.  
  114. % BOP -- beginning of page
  115. % Usage -- BOP
  116. /BOP
  117. {
  118.   clear
  119.   Mtrx setmatrix
  120.   25 0 translate % Physical page origin is at (-25,0) from the top left corner
  121. } bdf
  122.  
  123. % ch-fieldname -- extract field from ch-data array (order defined by positions
  124. % in first array argument to macro D)
  125. % Usage -- ch-fieldname
  126. /ch-image  {ch-data 0 get} bdf    % the bitmap hex string image
  127. /ch-xoff   {ch-data 1 get} bdf    % pixels from left edge of bitmap to char origin
  128. /ch-yoff   {ch-data 2 get} bdf    % pixels from top edge of bitmap to char origin
  129. /ch-width  {ch-data 3 get} bdf    % bitmap width in pixels
  130. /ch-height {ch-data 4 get} bdf  % bitmap height in pixels
  131. /ch-tfmw   {ch-data 5 get} bdf    % pixels to next character (precise flt value)
  132.  
  133. % CharBuilder -- image one character
  134. % Usage -- fontdict ch CharBuilder
  135. /CharBuilder
  136. {
  137.   /ch-code exch def        % save the char code
  138.   /font-dict exch def        % and the font dict.
  139.   /ch-data font-dict /BitMaps get
  140.     ch-code get def        % get the bitmap descriptor for char
  141.   ch-data null eq not        % show character if entry is not empty
  142.   {
  143.     ch-tfmw                0
  144.     ch-xoff neg            ch-yoff ch-height sub
  145.     ch-width ch-xoff sub    ch-yoff
  146.     setcachedevice
  147.     ch-width ch-height true [ 1 0 0 -1 ch-xoff ch-yoff ]
  148.     {ch-image} imagemask
  149.   } if
  150. } bdf
  151.  
  152.  
  153. % D -- define new character in current font
  154. % Usage -- [<bitmap> xoff yoff pixwid pixht tfmpixwid] charnum D
  155. /D
  156. {
  157.   /ch-code exch def
  158.   /ch-data exch def
  159.   currentfont /BitMaps get ch-code ch-data put
  160.   currentfont /Encoding get ch-code dup 3 string cvs cvn put
  161. } bdf
  162.  
  163. % EOJ -- end of job
  164. % Usage -- EOJ
  165. /EOJ
  166. {
  167.   end                % matches begin issued before BOJ
  168. } bdf
  169.  
  170. % EOP -- end of page
  171. % Usage -- ncopies EOP
  172. /EOP
  173. {
  174. /#copies exch def
  175. showpage
  176. } bdf
  177.  
  178. % LANDSCAPE -- landscape format page (11inH x 8.5inV)
  179. % Usage -- LANDSCAPE
  180. /LANDSCAPE
  181. {
  182.   letter initmatrix
  183.   72 Resolution div dup scale
  184.   0 3300 translate
  185.   -90 rotate
  186.   Mtrx currentmatrix pop
  187. } bdf
  188.  
  189. % LEGAL -- legal format page (8.5inH x 13inV)
  190. % Usage -- LEGAL
  191. /LEGAL
  192. {
  193.   legal initmatrix
  194.   72 Resolution div dup scale
  195. } bdf
  196.  
  197. % LETTER -- letter format page
  198. % Usage -- LETTER
  199. /LETTER
  200. {
  201.   letter initmatrix
  202.   72 Resolution div dup scale
  203.   Mtrx currentmatrix pop
  204. } bdf
  205.  
  206. % M -- moveto
  207. % Usage -- x y M
  208. /M
  209. {
  210.   moveto
  211. } bdf
  212.  
  213. % Mtrx -- permanent storage for page transformation matrix
  214. % Usage -- Mtrx
  215. /Mtrx 6 array def
  216.  
  217. % NF -- define new font
  218. % Usage -- /fontname NF
  219. /NF
  220. {
  221.   /newname exch def
  222.   newname 7 dict def
  223.   newname load
  224.   begin
  225.     /BitMaps 128 array def
  226.     /BuildChar { CharBuilder } def
  227.     /Encoding 128 array def
  228.     0 1 127 { Encoding exch /.notdef put } for
  229.     /FontBBox [ 0 0 1 1 ] def
  230.     /FontMatrix [ 1 0 0 1 0 0 ] def
  231.     /FontType 3 def
  232.   end
  233.   newname newname load definefont pop
  234. } bdf() pop
  235.  
  236. % NOTE -- note format page (increases available virtual memory from 240K
  237. %      to 340K on Apple LaserWriter)
  238. % Usage -- NOTE
  239. /NOTE
  240. {
  241.   note initmatrix
  242.   72 Resolution div dup scale           % set scaling to 1.
  243.   Mtrx currentmatrix pop
  244. } bdf
  245.  
  246. % P -- show string at current point, updating horizontal position to new endpt
  247. % Usage -- (string) P
  248. /P {show} bdf() pop
  249.  
  250. % Q -- draw bar of last size set by B command at specified point
  251. % Usage -- x y Q
  252. /Q {moveto w h B} bdf() pop
  253.  
  254. % R -- move relative right and show string, updating horizontal position to
  255. %      new endpoint
  256. % Usage -- (string) xxx R
  257. /R {0 rmoveto show} bdf() pop
  258.  
  259. % Resolution -- device resolution in dots/inch
  260. % Usage -- Resolution
  261. /Resolution 300 def
  262.  
  263. % S -- move absolute and show string, updating horizontal position to new endpt
  264. % Usage -- (string) xxx yyy S
  265. /S {moveto show} bdf() pop
  266.  
  267. % SF -- set new font at scale nnn (nnn = 1 normally; 2 gives double size chars)
  268. % Usage -- nnn /fontname SF
  269. /SF {findfont exch scalefont setfont} bdf() pop
  270.  
  271. % T -- move absolute horizontally and show string, updating horizontal position
  272. % to new endpt
  273. % Usage -- (string) xxx T
  274. /T {currentpoint exch pop moveto show} bdf() pop
  275.  
  276. end                % TeXdict
  277.